package com.sc.pattern.countdown;

import java.util.stream.IntStream;

/**
 * Created  on 2018/1/13.
 *
 * @author sc
 */
public class Client {
    public static void main(String[] args) throws InterruptedException {
        CountDown countDown = new CountDown(5);

        IntStream.rangeClosed(1,5).forEach(i->new Thread(
                ()->{
                    System.out.println(i+"is working");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    countDown.down();
                }
        ).start());
        countDown.await();
        System.out.println("over");
    }
}
